home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / menus / mxmnu241.zip / NAVYTIME.MNU < prev    next >
Text File  |  1992-12-14  |  2KB  |  123 lines

  1. Comment
  2. ==========================================================
  3.  
  4. Copyright 1992 by Marc Perkel * All right reserved.
  5.  
  6. This program is used to call the Navy atomic clock and set all
  7. your file servers to the correct time.
  8.  
  9. =========================================================
  10. EndComment
  11.  
  12. var
  13.   CheckCarrierDetect
  14.   NumberToDial
  15.   TimeOffset
  16.  
  17. StandardIO
  18.  
  19. ;----- Set com port, number, and time offfset to match your system.
  20.  
  21. ComPort = Com2
  22. NumberToDial = 'ATTD 9,1-202-653-0351'
  23. TimeOffSet = 6   ;Central Standard Time
  24.  
  25. ComInitPort(1200,8,'N',1)        ;1200 baud access only
  26.  
  27. CheckCarrierDetect = not ComCD
  28.  
  29. Writeln
  30. Writeln '==> Calling Naval Atomic Clock'
  31. Writeln
  32.  
  33. CallClock
  34. SetTime(GetTimeString)
  35. ExitMenu
  36.  
  37. ;----- Procedures
  38.  
  39. Procedure SetTime (St)
  40. var H Servers Serv T
  41.  
  42.    St = Mid(St,11,6)
  43.    H = Value(Mid(St,1,2)) + 24 - TimeOffset mod 24
  44.    St = Str(H) + ':' + Mid(St,3,2) + ':' + Right(St,2)
  45.    T = TimeOf(St) + 1
  46.    Writeln 'Setting Time to: ==> ' DateString(T) ' ' TimeString(T)
  47.  
  48.    NovAttachedServers(Servers)
  49.  
  50.    Writeln
  51.    Loop Servers
  52.       Serv = Servers[LoopIndex]
  53.       Write 'Setting Server ' Serv ' Clock ... '
  54.       NovSetPreferredServer Serv
  55.       NovServerTime = T
  56.       Writeln
  57.    EndLoop
  58.    Now = T
  59.    ExitMenu
  60. EndProc
  61.  
  62.  
  63. Procedure GetTimeString
  64.    ComWatchCD
  65.    while True
  66.       CharLoop
  67.       if length(ComLastLine) = 20 then Return ComLastLine
  68.    endwhile
  69. EndProc
  70.  
  71.  
  72. Procedure TestAbort
  73. var Ch
  74.    if ComCDAbort
  75.       Writeln '[Carrier Dropped]'
  76.       ExitMenu
  77.    endif
  78.    if not KbdReady then Return
  79.    Ch = ReadKey
  80.    if Ch = ESC then ExitMenu
  81. EndProc
  82.  
  83.  
  84. Procedure CharLoop
  85.    TestAbort
  86.    if ComCharReady
  87.       Write ComReadChar
  88.    endif
  89. EndProc
  90.  
  91.  
  92. Procedure WaitFor (St)
  93.    while ComLastLine <> St
  94.       CharLoop
  95.    endwhile
  96. EndProc
  97.  
  98.  
  99. Procedure CallClock
  100.    ComWrite 'ATZ' CR
  101.    WaitFor ('OK')
  102.    Wait 20
  103.    ComWriteln NumberToDial CR
  104.    while True
  105.       CharLoop
  106.  
  107.       if pos('CONNECT',ComLastLine) > 0
  108.          Wait 100
  109.          Return
  110.  
  111.       elseif ComLastLine = 'BUSY'
  112.          ExitMenu
  113.  
  114.       elseif ComLastLine = 'NO DIALTONE'
  115.          ExitMenu
  116.  
  117.       elseif ComLastLine = 'NO CARRIER'
  118.          ExitMenu
  119.  
  120.       endif
  121.    endwhile
  122. EndProc
  123.